﻿#include "clock.h"

#include <windows.h>

Clock::Clock()
{
}

qint64 Clock::milliseconds_now()
{
	return QDateTime::currentMSecsSinceEpoch();
}

qint64 Clock::microseconds_now()
{
	static LARGE_INTEGER s_frequency;
	static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
	if (s_use_qpc) {
		LARGE_INTEGER now;
		QueryPerformanceCounter(&now);
		return now.QuadPart / s_frequency.QuadPart;
	}
	else {
		return GetTickCount();
	}
}